/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.workforce.common.tags;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

/**
 *
 * @author neo
 */
public class FieldListTag extends FieldBaseTag {
    private static final long serialVersionUID = -7171221188734773637L;

    protected String selected;
    protected String value;

    @Override
    public int doStartTag() throws JspException {
        try {
            JspWriter out = pageContext.getOut();
            //String mode = pageContext.getRequest().getParameter("mode");
            //mode = (mode == null) ? "ins" : mode;
            StringBuffer s = new StringBuffer();
            s.append("<select ");
            if (sid != null) {
                s.append("id=\"").append(sid).append("\" ");
            }
            if (name != null) {
                s.append("name=\"").append(name).append("\" ");
            }
            if (style != null) {
                s.append("style=\"").append(style).append("\" ");
            }
            if (sClass != null) {
                s.append("class=\"").append(sClass).append("\" ");
            }
            s.append(">\n");

//            if (selected.equals("")) {
//                s.append("<option value=\"").append("").append("\" selected>").append("").append("</option>\n");
//            } else {
//                s.append("<option value=\"").append("").append("\">").append("").append("</option>\n");
//            }
//            //}
//
            beginTag();
            out.print(s.toString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return EVAL_BODY_INCLUDE;
    }

    @Override
    public int doEndTag() throws JspException {
        try {
            JspWriter out = pageContext.getOut();
            out.print("</select>");
            endTag();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return super.doEndTag();
    }

    public void setSelected(String selected) {
        this.selected = selected;
    }

    public void setValue(String value) {
        this.value = value;
    }
    
    public void setSClass(String sclass) {
        this.sClass = sclass;
    }
}

